class Solution:
    # @return a boolean
    def isValid(self, s):
    	if len(s) <= 0:
    		return True
    	stack = []
    	for i in s:
    		if len(stack) == 0:
    			stack.append(i)
    		else:
    			if i in {'}',']',')'} :
    				if i == '}' and stack.pop() != '{':
    					return False
    				if i == ']' and stack.pop() != '[':
    					return False
    				if i == ')' and stack.pop() != '(':
    					return False
    			else:
    				stack.append(i)
    	return len(stack) == 0

if __name__ == '__main__':
	a = "({[}])"
	so = Solution()
	print(so.isValid(a))